package ar.edu.unicen.exa.isistan.archassis.view.dialogs;

import org.eclipse.swt.widgets.Composite;
import swing2swt.layout.BorderLayout;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;

public class LabeledTextComposite extends Composite {
	private Text text;

	/**
	 * Create the composite.
	 * @param parent
	 * @param labelText
	 * @param 
	 */
	public LabeledTextComposite(Composite parent, String labelText, boolean multiline) {
		super(parent, SWT.NONE);
		setLayout(new BorderLayout(10, 5));
		
		Label lblNewLabel = new Label(this, SWT.NONE);
		lblNewLabel.setAlignment(SWT.CENTER);
		lblNewLabel.setLayoutData(BorderLayout.WEST);
		lblNewLabel.setText(labelText);
		
		int multilineStyle = SWT.SINGLE;
		if (multiline) {
			multilineStyle = SWT.MULTI | SWT.V_SCROLL;
		}
		text = new Text(this, SWT.BORDER | multilineStyle);
		text.setLayoutData(BorderLayout.CENTER);

	}

	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}

	public String getText() {
		return text.getText();
	}

	public void setText(String text) {
		this.text.setText(text);
	}

	@Override
	public void setEnabled(boolean enabled) {
		super.setEnabled(enabled);
		this.text.setEnabled(enabled);
	}
	
}
